package cn.itcast.rabbitmq.work;

import cn.itcast.rabbitmq.util.ConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class Producer {
    static final String QUEUE_NAME = "work_queue";

    public static void main(String[] args) throws Exception{
//        创建连接
       Connection connection = ConnectionUtil.getConnection();
//        创建频道
          Channel channel = connection.createChannel();
//        声明队列
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);
        for(int i = 1;i<=30;i++) {
//        发送消息
            String message = "傻吊+1" + i;
            channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
        }
//         关闭资源
        channel.close();
        connection.close();
    }
}
